App.controller('reimburseCheckController', ['$rootScope', '$scope', '$state', 'Page', function($rootScope, $scope, $state, Page) {

    $scope.grid = {
        options : {
            lazy : true
        },
        check : function(row) {
            $scope.reimburseCheck = row;
            $scope.modal.show();
        },
        view : function(row) {
            $scope.reimburseCheck = row;
            $scope.viewFlag = true;
            $scope.modal.show();
        },
        save : function() {
            Page.ajaxPost('reimburseBill/reimburseCheck.do', $scope.reimburseCheck, function(){
                Page.notice("操作成功!");
                $scope.modal.hide();
                $scope.queryToCheckBill();
            })
        },
        column_defs: [{
            target : 9,
            buttons : [
                {
                    name: '审批',
                    class: 'btn-warning btm-sm',
                    icon: 'glyphicon glyphicon-leaf',
                    event: 'check',
                    visiable : function(row) {
                        if(row.status == '2') {
                            return true;
                        } else {
                            return false;
                        }
                    }
                },
                {
                    name: '查看',
                    class: 'btn-info',
                    icon: 'glyphicon glyphicon-eye-open',
                    event: 'view',
                    visiable : function(row) {
                        if(row.status == '3') {
                            return true;
                        } else {
                            return false;
                        }
                    }
                }
            ]
        }]
    };

    $scope.$on('$viewContentLoaded', function() {
        $scope.queryToCheckBill();
    });

    $scope.queryToCheckBill = function() {
        $scope.grid.query({'status' : '2,3'});
    }

}]);